<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/util.js"></script>
    <script>
        function $(elementId){
            return document.getElementById(elementId);
        }
        var id = getQuery("id");
        window.onload = function (){
            findByItem(1);
        }
        function findByItem(pageNnm) {
             axios.get("/post/findByItem", {
                params: {
                    id: this.id,
                    pageNnm: pageNnm,
                    title: $("title").value,
                    acc: $("name").value,
                    start: $("start").value,
                    end: $("end").value
                }
            }).then(e => {
                var info = e.data;
                var str = "";
                for (var i = 0; i < info.list.length; i++) {
                    var obj = info.list[i];
                    str += `<tr><td><a href="/html/reply.html?id=${obj.id}">${obj.title}</a></td><td>${obj.user.acc}</td><td>${obj.replyNum}</td>
                <td>${obj.date}</td></tr>`;
                }
                $("pD").innerHTML = str;

                 var pStr ="";
                 for (var i = 1 ;i<=info.pages;i++){
                     pStr +=`<a href ="javascript:findByItem(${i})">${i}</a>`
                 }
                 $("fyDiv").innerHTML = pStr;


            })
        }

        function addPost(){
            location.href ="addPost.html";
        }












    </script>
</head>
<body>
<table border="1" cellspacing="0" width="60%">
    <thead><tr><th>标题</th><th>作者</th><th>回帖数量</th><th>发帖时间</th></tr></thead>
    <tbody id="pD">
    </tbody>
</table>

主题名称:<input type="text" id="title">
作者:<input type="text" id="name">
起始日期:<input type="text" id="start">
结束日期:<input type="text" id="end">
<input type="button" value="查询" onclick="findByItem(1)">

<div id="fyDiv"></div>
<input type="button" onclick="addPost()" value="发表话题">

</body>
</html>